<include file='Public/payheader' />
	 <style >
	   #mainbody{
			width:80%;
			margin-left:10%;
	   }
		#tright{
			float:left;
			margin-left:240px;
		}
		.p1{
			float:left;
			margin-left:0px;
			margin-top:24px;
		}
		.p2{
			float:left;
			margin-left:0px;
			margin-top:28px;
		}
		.p3{
			float:left;
			margin-left:0px;
			margin-top:22px;
		}
		#bottom{
			width:100%;
			margin-left:75%;
		}
     </style>
	 <script>
		//得到上一个同一个div下的节点
		function getNextElement(node){    
			if(node.nextSibling.nodeType == 1){    //判断下一个节点类型为1则是“元素”节点   
				return node.nextSibling;    
			}    
			if(node.nextSibling.nodeType == 3){      //判断下一个节点类型为3则是“文本”节点  ，回调自身函数  
				return getNextElement(node.nextSibling);    
			}    
			return null;
		}
		//减号
		function butjian(elem){
			val=getNextElement(elem);
			if(val.value==1) return null;
			val.value--;
			
			id=getPreElement(elem).value;
			tid="t"+id;
			pid="p"+id;
			total=document.getElementById(tid);
			price=document.getElementById(pid);
			//alert(parseFloat(price.innerHTML));
			total.innerHTML=parseInt(val.value)*parseFloat(price.innerHTML)+"元";
			
			gp=document.getElementById('goodpricies');//总金额
			alltotal=parseFloat(gp.innerHTML)-parseFloat(price.innerHTML);
			gp.innerHTML=alltotal+"元";
		}
		function getPreElement(node){    
			if(node.previousSibling.nodeType == 1){    //判断下一个节点类型为1则是“元素”节点   
				return node.previousSibling;    
			}    
			if(node.previousSibling.nodeType == 3){      //判断下一个节点类型为3则是“文本”节点  ，回调自身函数  
				return getPreElement(node.previousSibling);    
			}    
			return null;
		}
		//加号
		function butjia(elem){
			val=getPreElement(elem);
			val.value++;
			
			id=getNextElement(elem).value;
			tid="t"+id;
			pid="p"+id;
			total=document.getElementById(tid);
			price=document.getElementById(pid);
			//alert(parseFloat(price.innerHTML));
			total.innerHTML=parseInt(val.value)*parseFloat(price.innerHTML)+"元";
			
			
			
			gp=document.getElementById('goodpricies');//总金额
			alltotal=parseFloat(gp.innerHTML)+parseFloat(price.innerHTML);
			//alert(parseFloat(gp.innerHTML));
			gp.innerHTML=alltotal+"元";
		}
	 </script>
<!--头部-->
<div id="top">
	<span id="tleft">
		<img src="__PUBLIC__/assest/image/shoplogo.jpg" width="300px">	
	</span>
	<span id="tright" align="center">
		<div class="p1"><img src="__PUBLIC__/assest/image/icon/08.png" width="80px"><p>我的购物车</p></div>
		<div class="p2"><img src="__PUBLIC__/assest/image/icon/02.png" width="100px"><p>确认订单</p></div>
		<div class="p2"><img src="__PUBLIC__/assest/image/icon/03.png" width="100px"><p>成功提交订单</p></div>
		<div class="p3"><img src="__PUBLIC__/assest/image/icon/04.png" width="80px"><p>付款成功</p></div>
	</span>
<hr width="100%" style="margin-top:-5px;border:2px solid white;">
<hr width="100%" style="margin-top:-5px;border:2px solid green;">
</div>

<div id="mainbody">
	<form action="{:U('Pay/shdz')}" method="post">
	<table class="table">
	<tr><th>商品名称</th><th>规格</th><th>价格</th><th>数量</th><th>金额</th></tr>
	<volist name="list" id="vo">
	<?php $picpath=str_replace("thumb_","",$vo['pic']);	?>
	<tr>
	<td><a href="{:U('List/showgood',array('id'=>$vo[gid]))}"><img src='__PUBLIC__/photo/{$picpath}' 
	width="80px">{$vo.gname}</a></td>
	<td>{$vo.danwei}/份</td>
	<td><p id="p{$vo.gid}">{$vo.price}元</p></td>
	<td>
		<input class="add"  type="hidden" value="{$vo.gid}"/>
		<input class="min" name="" type="button" value="-" onclick="javascript:butjian(this)"/>
		<input class="text_box" name="goodnum[]" type="text" value="{$vo.num}" style="width:25px;" />
		<input class="add" name="" type="button" onclick="javascript:butjia(this)" value="+"/>
		<input class="add"  type="hidden" value="{$vo.gid}"/>
	</td>
	<td><p id="t{$vo.gid}">{$vo.total}元</p></td>
	
		<input name="gid[]" type="hidden"  value="{$vo.gid}" />
		<input name="danwei[]" type="hidden"  value="{$voo.danwei}" />
		<input name="pic[]" type="hidden"  value="{$picpath}" />
		<input name="price[]" type="hidden"  value="{$voo.price}" />
		<input name="gname[]" type="hidden"  value="{$vo.gname}" />
	</tr>					
	</volist>
	</table>
	<hr>
	<div id="bottom">
		商品金额<p id="goodpricies">{$alltotal}元</p>
		<input type="submit" class="btn-primary" value="提交订单">
	</div>
	</form>
</div>
<include file='Public/footer' />
</body>

</html>
